package com.wy.multilevelpulldown;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.util.List;

/**
 * Time:8/31/21
 * Author:ypf
 * Description:
 */
public class CommonMenuAdapter extends MenuBaseAdapter {

    private Context context;
    private List<String> tabList;

    public CommonMenuAdapter(Context context, List<String> tabList) {
        this.context = context;
        this.tabList = tabList;
    }

    @Override
    public void overrideCloseMenu(View tabView) {
        TextView tabTv = tabView.findViewById(R.id.textView);
        tabTv.setTextColor(Color.BLACK);
    }

    @Override
    public void overrideOpenMenu(View tabView, int position) {
        TextView tabTv = tabView.findViewById(R.id.textView);
        tabTv.setTextColor(Color.RED);
    }

    @Override
    public int getCount() {
        return tabList.size();
    }

    @Override
    public View getMenuView(int position, FrameLayout menuContainerView, ListPopuScreenMenuView parent) {
        View view = LayoutInflater.from(context).inflate(R.layout.view_content, parent, false);
        TextView textView = view.findViewById(R.id.textView);
        textView.setText("第" + tabList.get(position) + "个页面");
        textView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                notifyCloseMenu();
            }
        });
        return view;
    }

    @Override
    public View getTabView(int position, LinearLayout tabContainerView, ListPopuScreenMenuView parent) {
        View view = LayoutInflater.from(context).inflate(R.layout.view_title, parent, false);
        TextView textView = view.findViewById(R.id.textView);
        textView.setText("tab" + tabList.get(position));
        return view;
    }

}